﻿
function mysharetime(shareUrl, imgUrl, tTitle, tContent, appid, timestamp, nonceStr, signature, fn) {;
    var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=";
    var otherpara = "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
    var redirect_uri = encodeURIComponent(shareUrl);
    var timeLineLink = link + redirect_uri + otherpara;
    wx.config({
        debug: false,
        appId: appid,
        timestamp: timestamp,
        nonceStr: nonceStr,
        signature: signature,
        jsApiList: [
          'onMenuShareTimeline',
          'onMenuShareAppMessage'
        ]
    });
    wx.ready(function () {
        //alert("wx.ready");
        //分享朋友圈
    
        wx.onMenuShareTimeline({
            title: tTitle,
            desc: tContent, // 分享描述
            link: timeLineLink,
            imgUrl: imgUrl,
            trigger: function (res) {
               
            },
            success: function (res) {
                if (fn) fn();
            },
            cancel: function (res) {
               
            },
            fail: function (res) {
                
            }
        });
        //分享朋友
        wx.onMenuShareAppMessage({
            title: tTitle,
            desc: tContent,
            link: timeLineLink,
            imgUrl: imgUrl,
            trigger: function (res) {
               
              
            },
            success: function (res) {
                
                if (fn) fn();
            },
            cancel: function (res) {
                
            },
            fail: function (res) {
               
            }
        });
    });
    //分享错误提示
    wx.error(function (res) {
        //alert(res.errMsg);
    });
}
